/*
 * Created on 16/05/2005
 */
package tp.controller;

import tp.model.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

/**
 * @author Nicolas
 */
public class KeyboardController extends KeyAdapter {

	// Es una re
	private Nave miNave;

	private Posicion bordeDer, bordeIzq;
	

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.awt.event.KeyListener#keyPressed(java.awt.event.KeyEvent)
	 */
	public void keyPressed(KeyEvent e) {
		if (Controlador.isCorriendo()) {
			super.keyPressed(e);

			if (e.getKeyCode() == KeyEvent.VK_RIGHT)
				miNave.moverEnXDerecha(bordeDer.getXInt());

			else if (e.getKeyCode() == KeyEvent.VK_LEFT)
				miNave.moverEnXIzquierda(bordeIzq.getXInt());

			else if (e.getKeyCode() == KeyEvent.VK_SPACE)
				miNave.expulso();
		}
	}
	
	
	public KeyboardController(Nave unaNave, Posicion bDer, Posicion bIzq) {
		miNave = unaNave;
		bordeDer = bDer;
		bordeIzq = bIzq;
	}

}
